/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2024-2024.
 * Description: RTOS pac init functions
 * Author: wanghuizhao
 * Create: 2024-03-30
 */
#include <linux/libfdt.h>
#include <asm/fixmap.h>

extern phys_addr_t __fdt_pointer __initdata;

uint64_t __init pac_init_check(void)
{
	void *fdt = NULL;
	int size, node;
	const uint8_t *cmdline = CONFIG_CMDLINE;

	early_fixmap_init();
	fdt = fixmap_remap_fdt(__fdt_pointer, &size, PAGE_KERNEL);
	if (!fdt)
		return 0;

	node = fdt_path_offset(fdt, "/chosen");
	if (node < 0)
		return 0;

	if (!IS_ENABLED(CONFIG_CMDLINE_FORCE)) {
		const uint8_t *prop = fdt_getprop(fdt, node, "bootargs", NULL);

		if (prop)
			cmdline = prop;
	}

	if (strstr(cmdline, "arm64.nopauth"))
		return 0;

	return 1;
}

